<template>
	<view class="">
	  <form @submit="formSubmit" @reset="formReset">
	  <view class="message_list">
			<view class="message_item flex_layout">
				<view class="left_name">申请人姓名</view>
				<view class="flex_layout right_input">
					<input type="text" name='user_name'  value="" placeholder="请输入申请人姓名" placeholder-style="color:#999" />
				</view>
			</view>
			
			<view class="message_item flex_layout">
				<view class="left_name">申请人手机</view>
				<view class="flex_layout right_input">
					<input type="number" name='user_mobile'  value="" placeholder="请输入申请人手机" placeholder-style="color:#999" />
				</view>
			</view>
			
			<view class="message_item flex_layout">
				<view class="left_name">门店编码</view>
				<view class="flex_layout right_input">
					<input type="text" name='user_code'  value="" placeholder="请输入门店编码" placeholder-style="color:#999" />
				</view>
			</view>
			
			<view class="message_item flex_layout">
				<view class="left_name">门店密码</view>
				<view class="flex_layout right_input">
					<input type="password" name='user_password' value="" placeholder="请输入门店密码" placeholder-style="color:#999" />
					<!-- <image src="../../static/images/right.png" mode=""></image> -->
				</view>
			</view>
			
			<view class="submit_btn">
				<button class="btn-submit" formType="submit" type="primary">绑定</button>
			</view>
	  </view>
	  </form>
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				userinfo: this.$common.userInfo(),
				avatar:'',
				uploadTp:false,
				clinicBoole:false,
				keywords:'',
				clinicNameArry:[],
				clinic_name:'',
				clinic_id:'',
				clinicArray:[]
			}
		},
		onLoad() {
			
		},
		mounted() {
			_this= this;
		},
		onShow() {
			
		},
		computed: {
			
		},
		methods: {
			formSubmit: function(e) {
				var that=this;
				var value=e.detail.value;
				if (value.user_name == "") {
					uni.showToast({
						title: '申请人姓名不能为空',
						duration: 1500,
						icon: "none"
					});
					return
				}
				if (value.user_mobile == "") {
					uni.showToast({
						title: '申请人手机不能为空',
						duration: 1500,
						icon: "none"
					});
					return
				}
				if(!that.$common.testString(value.user_mobile,'mobile')){
					uni.showToast({
						title: '手机号格式不正确',
						duration: 1500,
						icon: "none"
					});
					return
				}
				if (value.user_code == "") {
					uni.showToast({
						title: '门店编码不能为空',
						duration: 1500,
						icon: "none"
					});
					return
				}
				
				if (value.user_password == "") {
					uni.showToast({
						title: '门店密码不能为空',
						duration: 1500,
						icon: "none"
					});
					return
				}
				
				this.$api.bindMyClinic(
				  {
						'user_name':value.user_name,
						'user_mobile':value.user_mobile,
						'user_code':value.user_code,
						'user_password':value.user_password
					},
					res => {
						if (res.code == 1) {
							//console.log(res);
							uni.showToast({
								title: res.msg,
								icon: "none",
								duration: 1500
							})
							setTimeout(function(){
								uni.navigateTo({
									url:'../user/user'
								})
							},1500)
							
						}
						if (res.code == 0) {
							uni.showToast({
								title: res.msg,
								icon: "none",
								duration: 1000
							})
						}
					}
				)
				
				
				
			}
			
		}
	}	
</script>

<style>
	@import url('../../common/common.css');
	page{background: #fff;}
	.flex_layout{display: flex; align-items: center; flex-wrap: wrap;}
	.message_item{padding: 50upx 30upx; border-bottom: 1px solid #f2f2f2;}
	.message_textarea_item{align-items: flex-start; border: none;}
	.face {
		text-align: center;
		padding-top: 60upx;
	}
	
	.face_img{width: 150upx; height: 150upx; position: relative; overflow: hidden; border-radius: 50%; margin: 0 auto;}
	
	.face_img>image {
		width: 150upx;
		height: 150upx;
		border-radius: 150upx
	}
	.message_item:last-child{border: none} 
	.left_name{width: 160upx; color: #333; font-size: 30upx;}
	.right_input{padding-left: 57upx; width: 530upx; justify-content: space-between;}
	.right_input button{width: 60upx; height: 35upx; margin: 0; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 22upx; color: #fff; border-radius: 5px; background: #2562a1;}
	.right_input input{width: 500upx; padding: 0 20upx; box-sizing: border-box; color: #333; font-size: 30upx;}
	.right_button{position: relative;}
	.right_button input{width: 450upx;}
	.inquiry_hospital{position: absolute; padding-left: 60upx; left: 0; top: 80upx; z-index: 80; height: 500upx; overflow-y: auto; background: #fff;}
	.hospital_item{padding: 15upx 30upx; color: #333; font-size: 24upx; border-bottom: 1px solid #f0f0f0;}
	.hospital_item:last-child{border: none;}
	.right_input textarea{width: 500upx; padding: 20upx; box-sizing: border-box; color: #333; font-size: 30upx; min-height: 120upx; border: 1px solid #f0f0f0;}
	.right_input picker{width: 500upx; padding-right: 30upx; box-sizing: border-box; color: #333; font-size: 30upx;}
	.right_input image{width: 13upx; height: 23upx; display: block;}
	.right_input .pickerDate{color: #999; font-size: 30upx;}
	.right_input .active{color: #333;}
	.sexLabel{margin-right: 30upx;}
	.sexLabel view radio{margin-right: 10upx;}
	.submit_btn button{width: 540upx; height: 72upx; border-radius: 72upx; background: #2562a1; color: #fff; font-size: 36upx;}
	.picker_color1{color: #ccc; font-size: 30upx;}
	.picker_color2{color: #333; font-size: 30upx;}
</style>
